package com.bys.admin.ai.controller;

import com.bys.admin.ai.controller.vo.ChatModelPageReqVO;
import com.bys.admin.ai.controller.vo.ChatModelSaveReqVO;
import com.bys.admin.ai.entity.ChatModel;
import com.bys.admin.ai.service.ChatModelService;
import com.bys.response.R;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import javax.validation.constraints.*;
import javax.validation.*;

import java.util.*;
import java.io.IOException;

import com.bys.vo.PageVo;
import static com.bys.response.R.success;

@Tag(name = "管理后台 - ai 聊天模型")
@RestController
@RequestMapping("/ai/chat-model")
@Validated
public class ChatModelController {

    @Resource
    private ChatModelService chatModelService;

    @PostMapping("/create")
    @Operation(summary = "创建ai 聊天模型")
    public R<Boolean> createChatModel(@Valid @RequestBody ChatModelSaveReqVO createReqVO) {
    chatModelService.createChatModel(createReqVO);
    return success(true);
    }

    @PutMapping("/update")
    @Operation(summary = "更新ai 聊天模型")
    public R<Boolean> updateChatModel(@Valid @RequestBody ChatModelSaveReqVO updateReqVO) {
        chatModelService.updateChatModel(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除ai 聊天模型")
    @Parameter(name = "id", description = "编号", required = true)
    public R<Boolean> deleteChatModel(@PathVariable Long id) {
        chatModelService.deleteChatModel(id);
        return success(true);
    }

    @GetMapping("/get/{id}")
    @Operation(summary = "获得ai 聊天模型")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public R<ChatModel> getChatModel(@PathVariable Long id) {
        ChatModel ChatModel = chatModelService.getChatModel(id);
        return success(ChatModel);
    }

    @GetMapping("/page")
    @Operation(summary = "获得ai 聊天模型分页")
    public R<Page<ChatModel>> getChatModelPage(@Valid ChatModelPageReqVO pageReqVO) {
        Page<ChatModel> pageResult = chatModelService.getChatModelPage(pageReqVO);
        return success(pageResult);
    }
}